package Controleur;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Modele.MonteCarloSimulation;
import Vue.Fenetre;
import Vue.FenetreModifier;

public class FenetreModifierControleur {
	private FenetreModifier fm;
	private MonteCarloSimulation model= new MonteCarloSimulation();
	private Fenetre fen;
	
	public FenetreModifierControleur(FenetreModifier fm){
		this.fm=fm;
		this.fm.modifierValeurListener(new classModifierVal());
		this.fm.cancelListener(new classCancel());
	}
	
	class classModifierVal implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			
			model.setS(Double.parseDouble(fm.getJtf1().getText()));
			model.setX(Double.parseDouble(fm.getJtf2().getText()));
			model.setR(Double.parseDouble(fm.getJtf3().getText()));
			model.setT(Double.parseDouble(fm.getJtf4().getText()));
			model.setB(Double.parseDouble(fm.getJtf5().getText()));
			model.setV(Double.parseDouble(fm.getJtf6().getText()));
			model.setnSteps(Integer.parseInt(fm.getJtf7().getText()));
			model.setnSimulations(Integer.parseInt(fm.getJtf8().getText()));
			fm.dispose();
			System.out.println(model.getS()+" "+model.getX()+" "+model.getR()+" "+model.getT()+" "+model.getB()+" "+model.getV()+" "+model.getnSteps()+" "+model.getnSimulations());
			model.calcule(fen.getCombo().getSelectedItem().toString());
		}
		
	}
	
	class classCancel implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			fm.dispose();
			
		}
		
	}

}
